<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core">


<ui:composition template="/WEB-INF/templates/maintemplate.xhtml">
	<ui:define name="metadata">
		<f:metadata>
			<f:viewParam name="#{constants.nameToValueMap.CATEGORY__THREAD_ID}" value="${sessionScope.ctgid}"></f:viewParam>
		</f:metadata>
	</ui:define>
	<ui:define name="navigation">
		<ui:include src="/navigation.xhtml"></ui:include>
	</ui:define>
	<ui:define name="content">
		<f:event type="preRenderView" listener="#{threadBackingBean.loadThreads}" />

		<h:form prependId="true">
			<t:dataTable id="threadTable" value="#{threadBackingBean.threads}" var="thread" rows="10" binding="#{threadBackingBean.htmlDataTable}"
				styleClass="dataTableStyle" columnClasses="threadcolumclass" headerClass="dataTableheaderStyle" rowClasses="oddRow,evenRow">
				<h:column>
					<f:facet name="header">
						<!-- header components go here -->
						<h:outputText value="#{msgs.threadSubjectLabel}"></h:outputText>
					</f:facet>
					<h:link value="#{thread.subject}" outcome="viewthread" styleClass="longstyle">
						<f:param name="id" value="#{thread.id}"></f:param>
					</h:link>
					<f:attribute name="style" value="width:60%"></f:attribute>
				</h:column>

				<h:column>
					<f:facet name="header">
						<!-- header components go here -->
						<h:outputText value="#{msgs.threadReplyHitLabel}"></h:outputText>
					</f:facet>
					<h:outputText value="#{thread.content}" escape="false"></h:outputText>
				</h:column>

				<h:column>
					<f:facet name="header">
						<!-- header components go here -->
						<h:outputText value="#{msgs.threadAuthorLabel}"></h:outputText>
					</f:facet>

					<h:commandButton value="Delete" action="#{threadBackingBean.deleteThread(thread)}">
						<f:ajax event="action" render="@form" onerror="handleAjaxError"></f:ajax>
					</h:commandButton>
				</h:column>
			</t:dataTable>
			<div class="pagerStyle">
				<div style="display: inline; float: left; margin-top: 10px;">
					<h:button value="#{msgs.postNewThread}" outcome="/thread/createthread.xhtml"></h:button>
				</div>
				<div class="scroller">
					<t:dataScroller id="scroll_1" for="threadTable" fastStep="10" pageCountVar="pageCount" pageIndexVar="pageIndex" styleClass="scroller"
						paginator="true" paginatorMaxPages="9" paginatorTableClass="paginator" paginatorActiveColumnStyle="font-weight:bold;font-size:large"
						immediate="true">
						<f:facet name="first">
							<h:graphicImage library="images" name="arrow-first.gif" />
						</f:facet>
						<f:facet name="last">
							<h:graphicImage library="images" name="arrow-last.gif" />
						</f:facet>
						<f:facet name="previous">
							<h:graphicImage library="images" name="arrow-previous.gif" />
						</f:facet>
						<f:facet name="next">
							<h:graphicImage library="images" name="arrow-next.gif" />
						</f:facet>
						<f:facet name="fastforward">
							<h:graphicImage library="images" name="arrow-ff.gif" />
						</f:facet>
						<f:facet name="fastrewind">
							<h:graphicImage library="images" name="arrow-fr.gif" />
						</f:facet>
						<f:ajax render="@form" execute="@form" onerror="handleAjaxError">
						</f:ajax>
					</t:dataScroller>
					<t:dataScroller id="scroll_2" for="threadTable" pageCountVar="pageCount" pageIndexVar="pageIndex" paginator="false" immediate="true"
						styleClass="scroll_2">
					Pages: #{pageIndex}/#{pageCount}
					</t:dataScroller>
				</div>
			</div>
		</h:form>

	</ui:define>
</ui:composition>

</html>